<template>
  <div id="bbt">
    <div class="top">
      <div class="logo"><i>爆爆团</i></div>
      <div class="title">限时爆款 超级低价</div>
      <div class="option">
        <div :class="{inbuy:true,active:nowlist==0}" @click="inbuy">正在抢购</div>
        <div :class="{preview:true,active:nowlist==1}" @click="preview">上新预告</div>
      </div>
    </div>
    <div class="list">
      <div class="food" v-for="(item, index) in datalist" :key="index">
        <div class="pic">
          <img :src="item.picture" alt="" />
        </div>
        <div class="right">
          <div>肯德基</div>
          <div>{{ item.name }}</div>
          <p>爆爆团价</p>
          <div class="pres">
            <div>{{ item.min_price }}</div>
            <span>{{ item.promotion_info }}</span>
          </div>
          <div class="rob">
            <button @click="changestate(item)">
              {{ item.status == 3 ? "已抢" : "马上抢" }}
            </button>
            <div>{{ item.month_saled_content }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { tuan_list } from "../api/index.js";
export default {
  data() {
    return {
      nowlist:0,
      foodlist1: [],
      foodlist2: [],
      datalist: [],
    };
  },
  methods: {
    inbuy() {
      this.datalist = this.foodlist1;
      this.nowlist = 0;
    },
    preview() {
      this.datalist = this.foodlist2;
      this.nowlist = 1;
    },
    changestate(item) {
      item.status = 3;
    },
  },
  mounted() {
    tuan_list({ status: 0 }).then((res) => {
      this.foodlist1 = res.data.list;
      this.datalist = this.foodlist1;
    });
    tuan_list({ status: 1 }).then((res) => {
      this.foodlist2 = res.data.list;
    });
  },
};
</script>

<style scoped>
#bbt {
  display: flex;
  flex-direction: column;
}
#bbt .top {
  position: fixed;
  width: 100%;
  height: 150px;
  background-color: rgb(251, 63, 16);
}
#bbt .top .logo {
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  font-weight: 700;
  color: white;
}
#bbt .top .title {
  text-align: center;
  line-height: 50px;
  font-size: 30px;
  color: gold;
  font-weight: 700;
}
#bbt .top .option {
  display: flex;
  line-height: 60px;
  color: white;
  margin-left: 10px;
}
#bbt .top .option div {
  margin-right: 30px;
}
#bbt .top .option div.active{
  color: gold;
  font-weight: 700;
}
#bbt .list {
  margin-top: 150px;
  flex: 1;
}
#bbt .list .food {
  display: flex;
  margin: 5px;
  padding: 10px;
  width: 94%;
  height: 150px;
}
#bbt .list .food .pic {
  width: 120px;
  height: 140px;
}
#bbt .list .food .pic img {
  width: 100%;
  height: 100%;
}
#bbt .list .food .right {
  margin-left: 5px;
  flex: 1;
}
#bbt .list .food .right > div:first-child {
  font-size: 14px;
  color: #ccc;
}
#bbt .list .food .right > div:nth-child(2) {
  font-weight: 700;
}
#bbt .list .food .right p {
  line-height: 40px;
  font-size: 14px;
  color: rgb(251, 63, 16);
}
#bbt .list .food .right .pres {
  float: left;
  color: rgb(251, 63, 16);
}
#bbt .list .food .right .rob {
  float: right;
}
#bbt .list .food .right .rob button {
  margin-bottom: 10px;
  padding: 5px 15px;
  border-radius: 20px;
  background-color: rgb(251, 63, 16);
  color: white;
  border: none;
}
#bbt .list .food .right .rob > div {
  color: rgb(251, 63, 16);
  font-size: 12px;
  text-align: center;
}
</style>